import instance from "@/utils/http.js";
import Api from "@/api/index.js";

//获取邮箱验证码
export const getEmailCode = (email) => {
    return instance({
        url: Api.askCode,
        method: 'post',
        data:{
            email
        }
    })
}

//获取图形验证码
export const getCheckCode = () => {
    return instance({
        url: Api.checkCode,
        method: 'get',
    })
}

//用户注册
export const register = data => {
    return instance({
        url: Api.register,
        method: 'post',
        data: {
            email: data.email,
            password: data.password,
            username: data.username,
            code: data.code
        }
    })
}

//验证码验证
export const codeCheckOk = data => {
    return instance({
        url: Api.codeCheckOk,
        method: 'post',
        data: {
            code: data.code,
            cokeKey: data.cokeKey
        }
    })
}

//用户账号密码登录
export const login = data => {
    return instance({
        url: Api.user_login,
        method: 'post',
        data: {
            username: data.username,
            password: data.password,
            code: data.code,
            cokeKey: data.cokeKey
        }
    })
}

//退出登录
export const logout = () => {
    return instance({
        url: Api.logout,
        method: 'post'
    })
}

//获取用户信息
export const getUserInfo = (username) => {
    return instance({
        url: Api.userInfo,
        method: 'post',
        data: {
            username
        }
    })
}